home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
001-025
/
scopedisk20
/
virusx15
/
virusx.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-18
|
23KB
|
836 lines
/* VirusX - by Steve Tibbett
The complete Virus Elimination System!
Please - if you find a new virus, Send me a copy!
(And warn me it's on the disk!). I want to keep
this program current. (Feel free to put something
neat on the disk also!)
History:
--------
A few weeks ago: V1.0 written.
A few days later: V1.01 released - V1.0 wrote garbage when disk was Write Prot.
27-Mar-88: V1.2 - Added Byte Bandit RAM detection, and disk detection.
(Actually, it's well after Midnight - make that 28-Mar-88)
Just after
uploading V1.2
to Amic BBS: Realized I put the wrong version in the ARC file - Had to
rename V1.2 to V1.21...
June 15, 1988: Created V1.3 which was just V1.21 cleaned up, made a bunch smaller.
July 8, 1988: Recieved Revenge virus Yesterday, disassembled it,
and added it to VirusX 1.4. Added ViewBoot and SCA check also.
July 24, 1988: Recieved the Byte Warrior virus, added it. V1.5
Viruses Dealt With:
Byte Bandit - RAM and Disk checked, TD vector patched,
resident module destroyed, Interrupt
patched.
SCA - Disk checked, CoolCapture checked, fixed
if it points to a known SCA virus.
Revenge - DoIO patched, Interrupt patched, Disk
checked.
Byte Warrior -
*/
#include <stdio.h>
#include <exec/types.h>
#include <intuition/intuition.h>
#include <devices/bootblock.h>
#include <devices/trackdisk.h>
#include <exec/execbase.h>
/* This stuff is for the detach module Manx provides, that's how
VirusX can be executed in the Startup Sequence and have the
initial CLI window close without any problems.
(but not until I get a version of 1.3 that works with it)
*/
/*
long _stack = 16000;
long _priority = 0;
long _BackGroundIO = 0;
char *_procname = "VirusX";
*/
/*
Created with Aztec C V3.6a using 32 bit ints.
(My makefile is included in the archive)
No longer uses Precompiled Headers, so it should compile OK.
*/
struct Port *diskport; /* disk's port.*/
struct IOStdReq *diskreq; /* disk's IOStdReq */
int DisksChecked,
DisksInstalled,
VirusesFound; /* for title bar info */
char titlebuffer[75]; /* Where tietie bar is kept */
/* Amount of boot code we've got bwlow (approx): */
#define BSIZE 40
char TDName[] = "trackdisk.device"; /* Saves space */
char copystring[] = "(Copy Count on this disk: %d)"; /* Again, saves space */
int ChangeCount[4]; /* TD_CHANGECOUNT for all 4 drives */
int LastSum; /* Used in the checksumming */
int CheckDrives; /* Boolean, from the command line */
int error; /* sort of a temporary variable sort of */
unsigned char diskbuffer[3*512];/* Everything ends up in here.
I suppose I should have AllocMem'ed this,
but it's SO easy this way
Note that this is 3*512, not 2*512. The reason
for this is that I have heard that the SCA will
attempt to rewrite itself whenever it sees a Read
request of 1024 bytes... So I read 3 blocks.
*/
/* Warning messages. These messages get modified before being displayed
(Unless you DO have a DF9:) */
char TEXTPTR[] = "Danger: The disk in DF9: is";
char NBCTEXT[] = "Danger: The disk in DF9: has"; /* What a waste, eh? */
char CopyText[40];
/* This is a byte by byte copy of working boot block code. Check it
out if you like. This is what gets written back to the disk when you
ask VirusX to fix a disk. */
unsigned char bootblock[] = { 'D', 'O', 'S', 0,
0xc0, 0x20, 0x0f, 0x19, 0x00, 0x00, 0x03, 0x70, 0x43, 0xfa, 0x00, 0x18,
0x4e, 0xae, 0xff, 0xa0, 0x4a, 0x80, 0x67, 0x0a, 0x20, 0x40, 0x20, 0x68,
0x00, 0x16, 0x70, 0x00, 0x4e, 0x75, 0x70, 0xff, 0x60, 0xfa, 0x64, 0x6f,
0x73, 0x2e, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x00, 0x00, 0x00,
0x00, 0x00};
struct TextAttr TxtAt_Plain = { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT};
/*** Non SCA warning requester IntuiText's ***/
struct IntuiText Body2 = { 0, 1, JAM2, 20,18, &TxtAt_Plain,
"Nonstandard Boot Code!", NULL };
struct IntuiText Body1 = {
0, 1, JAM2, 20, 8, &TxtAt_Plain, (UBYTE *)NBCTEXT, &Body2 };
struct IntuiText Pos = {
0, 1, JAM2, 7,3, &TxtAt_Plain, "Remove it", NULL };
struct IntuiText Neg = {
0, 1, JAM2, 7,3, &TxtAt_Plain, "Ignore it", NULL };
/***** SCA Danger Requester IntuiText's ******/
struct IntuiText SCABody2 = {
0, 1, JAM2, 20,18, &TxtAt_Plain,(UBYTE *) "infected with an SCA Virus!!", NULL };
struct IntuiText SCABody = {
0, 1, JAM2, 20, 8, &TxtAt_Plain, (UBYTE *)TEXTPTR, &SCABody2 };
struct IntuiText SCAPos = {
0, 1, JAM2, 7,3, &TxtAt_Plain, "Remove it", NULL };
struct IntuiText SCANeg = {
0, 1, JAM2, 7,3, &TxtAt_Plain, "Ignore it", NULL };
/***** BBANDIT Requester IntuiText's ******/
struct IntuiText BBDiskbody3 = {
0, 1, JAM2, 20,30, &TxtAt_Plain, CopyText, NULL };
struct IntuiText BBDiskbody2 = {
0, 1, JAM2, 20,18, &TxtAt_Plain,(UBYTE *) "infected with the Byte Bandit VIRUS!", &BBDiskbody3};
struct IntuiText BBDiskbody = {
0, 1, JAM2, 20, 8, &TxtAt_Plain, (UBYTE *)TEXTPTR, &BBDiskbody2 };
/***** Byte Warrior Requester IntuiText's ******/
struct IntuiText ByteWarriorBody2 = {
0, 1, JAM2, 20,18, &TxtAt_Plain,(UBYTE *) "infected with the Byte Warrior VIRUS!", 0};
struct IntuiText ByteWarriorBody = {
0, 1, JAM2, 20, 8, &TxtAt_Plain, (UBYTE *)TEXTPTR, &ByteWarriorBody2 };
/***** BBandit Notice - Removed from Memory ****/
struct IntuiText BBMem2 = {
0, 1, JAM2, 20,18, &TxtAt_Plain,(UBYTE *) "in memory, and is now disabled. See the", NULL};
struct IntuiText BBMem1 = {
0, 1, JAM2, 20,28, &TxtAt_Plain,(UBYTE *) "documentation for more information!", &BBMem2 };
struct IntuiText BBMem3 = {
0, 1, JAM2, 20,8, &TxtAt_Plain,(UBYTE *) "NOTICE: The Byte Bandit VIRUS was found", &BBMem1 };
struct IntuiText BBMPos = {
0, 1, JAM2, 7,3, &TxtAt_Plain, " Thanks! ", NULL };
/***** Byte Warrior Notice - Removed from Memory ****/
struct IntuiText ByteWarriorMem = {
0, 1, JAM2, 20,8, &TxtAt_Plain,(UBYTE *) "NOTICE: The Byte Warrior VIRUS was found", &BBMem1 };
/***** Revenge on Disk Requester IntuiText's ******/
struct IntuiText RevDiskbody3 = {
0, 1, JAM2, 20,30, &TxtAt_Plain, CopyText, NULL };
struct IntuiText RevDiskbody2 = {
0, 1, JAM2, 20,18, &TxtAt_Plain,(UBYTE *) "infected with the -Revenge- VIRUS!", &RevDiskbody3};
struct IntuiText RevDiskbody = {
0, 1, JAM2, 20, 8, &TxtAt_Plain, (UBYTE *)TEXTPTR, &RevDiskbody2 };
/***** Revenge Notice - Removed from Memory ****/
struct IntuiText RevMem = {
0, 1, JAM2, 20,8, &TxtAt_Plain,(UBYTE *) "NOTICE: The Revenge! VIRUS was found", &BBMem1 };
/***** Revenge Notice - Removed from Memory ****/
struct IntuiText SCAMem = {
0, 1, JAM2, 20,8, &TxtAt_Plain,(UBYTE *) "NOTICE: An SCA-type Virus was found", &BBMem1 };
/***** Write Protect Error Requester IntuiText's ******/
struct IntuiText ERRBody2 = {
0, 1, JAM2, 20,18, &TxtAt_Plain,(UBYTE *) "Write Protected.", NULL };
struct IntuiText ERRBody = {
0, 1, JAM2, 20, 8, &TxtAt_Plain, (UBYTE *)"DISK ERROR: Disk is", &ERRBody2 };
struct IntuiText ERRPos = {
0, 1, JAM2, 7,3, &TxtAt_Plain, "Retry", NULL };
struct IntuiText ERRNeg = {
0, 1, JAM2, 7,3, &TxtAt_Plain, "Cancel", NULL };
/***** Rewrite block? Really? ******/
struct IntuiText REWBody3 = {
0, 1, JAM2, 20,28, &TxtAt_Plain,(UBYTE *) "boot sectors?", NULL };
struct IntuiText REWBody2 = {
0, 1, JAM2, 20,18, &TxtAt_Plain,(UBYTE *) "rewrite that disk's boot", &REWBody3};
struct IntuiText REWBody = {
0, 1, JAM2, 20, 8, &TxtAt_Plain, (UBYTE *)"Are you sure you want to", &REWBody2 };
struct IntuiText REWPos = {
0, 1, JAM2, 7,3, &TxtAt_Plain, "Yes", NULL };
struct IntuiText REWNeg = {
0, 1, JAM2, 7,3, &TxtAt_Plain, "No!", NULL };
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Window *LittleWindow;
struct IntuiMessage *Message;
struct RastPort *RP;
int Keepgoing; /* a boolean flag. it's false when we want out. */
int x, y, i; /* left over from my using Basic */
/*** The Newwindow Structure. ***/
char TITLETEXT[] = "VirusX 1.50 by Steve Tibbett";
char text[] = "DF6: Boot Sectors"; /* for display thing */
struct NewWindow NewLittleWindow = {
128, /* Left, Top, Width, Height */
0,
309,
10,
0, /* Frontpen, Backpen */
1,
DISKINSERTED | CLOSEWINDOW | VANILLAKEY | MOUSEBUTTONS | NEWSIZE, /* IDCMP Flagz */
WINDOWDRAG | WINDOWDEPTH | RMBTRAP | WINDOWCLOSE | NOCAREREFRESH, /* Windo Flagz */
NULL,
NULL,
TITLETEXT, /* My name. Vous Touchez mon Name, Vous dies. */
NULL,
NULL,
0,
0,
0,
0,
WBENCHSCREEN,
};
/*********************Da Beginnin*************************/
main(argc, argv)
int argc, argv;
{
/* Come on, folks, is intuition ever NOT going to be available???? */
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
/* Same with GfxBase. If GfxBase is gone, we DESERVE to crash. */
GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0);
/* We use the same port/request through the whole program. Works OK. */
diskport = CreatePort(0,0);
diskreq = CreateStdIO(diskport);
LittleWindow = OpenWindow(&NewLittleWindow);
if (LittleWindow == NULL) exit(400L); /* No memory to open little window! */
RP = LittleWindow->RPort; /* easier than typing Move(LittleWindow->RP*/
/* This does some setup stuff, I guess, eh? */
SetUp();
/* Check for Byte Bandit, SCA, Revenge and ByteWarrior in RAM. */
CheckMemoryForViruses();
CheckBlock();
DoLittle(); /* The main loop. Do Little. Ya. */
DeletePort(diskport);
DeleteStdIO(diskreq);
}
/*********************/
DoLittle()
{
register int Code; /* for storing our IntuiMessage stuff */
register int Class;
register int KG2; /* KeepGoing 2. Another booleean. */
KG2 = TRUE;
SetAPen(RP, 1);
SetBPen(RP, 0);
SetDrMd(RP, JAM2);
while (KG2 == TRUE)
{
sprintf(titlebuffer, "VirusX: Disks Checked: %d Disks Installed: %d Viruses Found: %d", DisksChecked, DisksInstalled, VirusesFound);
SetWindowTitles(LittleWindow, -1, titlebuffer);
WaitPort(LittleWindow->UserPort);
Message = GetMsg(LittleWindow->UserPort);
Class = Message->Class;
Code = Message->Code;
ReplyMsg(Message);
if (Class == CLOSEWINDOW)
{
KG2 = FALSE;
continue;
};
if (Class == VANILLAKEY)
{
int flag;
flag = ShowAscii(Code);
if (flag == 1) CheckBlock();
};
if (Class == DISKINSERTED) CheckBlock();
};
CloseWindow(LittleWindow);
return;
}
/************************************************/
/* Opens trackdisk, finds out who's out there, */
/* and sets Changecount up accordioningly. */
/************************************************/
SetUp()
{
for (x = 0; x < 4; x++) /* go thru all 4 possible drives */
{
ChangeCount[x] = 1000;
error = OpenDevice(TDName,x,diskreq,0);
if (error > 0)
{
ChangeCount[x] = -1;
};
};
}
/*********************************************************/
/* This routine returns which drive changed disks lately */
/*********************************************************/
WhoChanged()
{
int RetVal; /* The value we'll return */
RetVal = -1; /* return -1 if all else fails */
for (x = 0; x < 4; x++)
{
if (ChangeCount[x] == -1) continue; /* no drive here */
error = OpenDevice(TDName,x,diskreq,0);
if (error > 0) continue; /* no drive here */
diskreq->io_Command = TD_CHANGESTATE;
DoIO(diskreq);
if (diskreq->io_Actual != 0)
{
continue;
};
diskreq->io_Command = TD_CHANGENUM;
DoIO(diskreq);
if (diskreq->io_Actual != ChangeCount[x])
{
RetVal = x;
ChangeCount[x] = diskreq->io_Actual;
CloseDevice(diskreq);
goto Out;
};
CloseDevice(diskreq);
};
Out:;
return(RetVal);
}
/****************************************************************/
/* Figures out which drive changed disks (using WhoChanged(), */
/* And checks it. Calling this after every DISKINSERTED is OK.*/
/****************************************************************/
CheckBlock()
{
/* How many register vars can I use, anyway? */
register int Sum, Bootable, Virus;
register int a, Unit;
register int SCA, ByteWarrior, Revenge, BBandit;
unsigned int *ptr;
while ((Unit = WhoChanged()) != -1)
{
DisksChecked++;
SCA = FALSE;
BBandit = FALSE;
Revenge = FALSE;
ByteWarrior = FALSE;
/* Unit # to open is returned by "WhoChanged()" up above. */
if (Unit == -1) return;
error = OpenDevice(TDName,Unit,diskreq,0);
if (error > 0) return;
/* I've heard stories that pulling a read request to block zero with a
length of 1024 will cause the virus to write itself back. Not taking
any chances. */
diskreq->io_Command = CMD_READ;
diskreq->io_Data = diskbuffer;
diskreq->io_Length = 3*512;
diskreq->io_Offset = 0;
DoIO(diskreq);
if (diskreq->io_Error > 19) return; /* disk error, lemme out */
diskreq->io_Length = 0;
diskreq->io_Command = TD_MOTOR;
DoIO(diskreq); /* turn off motor */
if (diskreq->io_Error > 19) return; /* disk error, lemme out */
CloseDevice(diskreq);
ptr = &diskbuffer[0];
Sum = 0;
for (a=0; a<256 /*1024/4 cuz we're dealing with ptr math now*/ ; a++)
{
LastSum = Sum;
Sum = Sum + ptr[a];
if (LastSum > Sum) Sum++; /* took me a while to figger this out */
}
if (Sum != 0)
{
return; /* if it's not bootable, we DONT want it! */
};
ptr = &diskbuffer[4];
if (diskbuffer[0x34] == 100)
if (diskbuffer[0xc4] == 48)
if (diskbuffer[0xb] == 89)
if (diskbuffer[0xf1] == 7)
{
VirusesFound++;
ByteWarrior = TRUE;
};
if (diskbuffer[0x2b] == '9')
if (diskbuffer[0x2c] == '.')
if (diskbuffer[0x2d] == '8')
if (diskbuffer[0x2e] == '7')
{
VirusesFound++;
BBandit = TRUE; /* 9.87 is part of BBandit Virus */
};
/* check specifically for SCA virus */
if (diskbuffer[8] == 'C')
if (diskbuffer[9] == 'H')
if (diskbuffer[10] == 'W')
{
SCA = TRUE; /* CHW is part of SCA virus */
VirusesFound++;
};
if (diskbuffer[0xe] == 'I')
if (diskbuffer[0xf] == 'D')
if (diskbuffer[0x10] == '9')
if (diskbuffer[0x1a6] == 'f')
{
Revenge= TRUE;
VirusesFound++;
};
/* compare boot block with real boot block. If it's not, notify God. */
Virus = FALSE;
for (x = 0; x < 39; x++) /* num of bytes in bootblock */
{
if (diskbuffer[8+x] != bootblock[8+x])
{
Virus = TRUE;
};
};
/* Oh no, a Virus! */
if (Virus == TRUE)
{
NBCTEXT[23] = '0'+Unit; /* change DF9: to real drive in text */
TEXTPTR[23] = '0'+Unit;
if (SCA == TRUE)
{
/* OH NOOOOO, an SCA virus. Wimpo virus, compared to BBandit
but it's a lot nicer code to read. */
Delay(1);
error = AutoRequest(LittleWindow, &SCABody, &SCAPos, &SCANeg, 0, 0, 320, 70);
if (error == TRUE) DoInstall(Unit); /* user wants it fixed. */
Delay(1);
}
else if (BBandit == TRUE)
{
/* The Byte Bandit Virus. Tricky bugger, he WAS. Cheats, tho. */
sprintf(CopyText, copystring, (diskbuffer[74]*256)+diskbuffer[75]);
error = AutoRequest(LittleWindow, &BBDiskbody, &SCAPos, &SCANeg, 0, 0, 380, 80);
if (error == TRUE) DoInstall(Unit); /* User crying for aid */
}
else if (Revenge == TRUE)
{
/* Revenge virus. X rated bugger, lot like Byte Bandit. */
sprintf(CopyText, copystring, (diskbuffer[0x3f6]*256)+diskbuffer[0x3f7]);
error = AutoRequest(LittleWindow, &RevDiskbody, &SCAPos, &SCANeg, 0, 0, 380, 80);
if (error == TRUE) DoInstall(Unit); /* User crying for aid */
}
else if (ByteWarrior == TRUE)
{
/* Byte Warrior. Very 'friendly' virus. Ez to get rid of. */
error = AutoRequest(LittleWindow, &ByteWarriorBody, &SCAPos, &SCANeg, 0, 0, 380, 70);
if (error == TRUE) DoInstall(Unit); /* User crying for aid */
}
else
{
/* Probably just a custom boot block (or a new virus...) */
error = AutoRequest(LittleWindow, &Body1, &Pos, &Neg, 0, 0, 320, 70);
if (error == TRUE) DoInstall(Unit); /* user wants it neutered. */
}
};
}; /* End of While Whochanged */
}
/********************************************/
/* This is where the boot code gets changed */
/********************************************/
DoInstall(un)
int un; /* unit to write to */
{
register int x;
register int Sum;
register int err, a;
/* Rewrite disk? Really? */
error = AutoRequest(LittleWindow, &REWBody, &REWPos, &REWNeg, 0, 0, 320, 75);
if (error != TRUE) return; /* user changed his brain. */
DisksInstalled++;
error = OpenDevice(TDName, un,diskreq,0);
if (error > 0) return;
trygain:
diskreq->io_Command = TD_PROTSTATUS;
DoIO(diskreq); /* check if disk is write protected */
if (diskreq->io_Actual != 0)
{
error = AutoRequest(LittleWindow, &ERRBody, &ERRPos, &ERRNeg, 0, 0, 280, 75);
if (error == TRUE) /* error is true or false, depending on user */
{
goto trygain;
};
CloseDevice(diskreq);
return; /* unrecoverable write protect error!!!!!!!!! */
};
for (x = 0; x < 1024; x++)
diskbuffer[x] = 0; /* clear diskbuffer to zero. clean. */
CopyMem(bootblock, diskbuffer, 50); /* Copy it over */
/* Write it ! */
{
error = 0;
diskreq->io_Length = 1024; /* here we go! */
diskreq->io_Data = &diskbuffer[0];
diskreq->io_Command = CMD_WRITE;
diskreq->io_Offset = 0L;
DoIO(diskreq);
error = diskreq->io_Error;
};
if (error < 19)
{
diskreq->io_Command = CMD_UPDATE; /* flush buffer to disk */
DoIO(diskreq);
error = diskreq->io_Error;
};
if (error < 19)
{
Delay(5);
diskreq->io_Length = 0;
diskreq->io_Command = ETD_MOTOR;
DoIO(diskreq); /* turn off motor */
error = diskreq->io_Error;
};
CloseDevice(diskreq);
if (error > 19)
{
SetWindowTitles(LittleWindow, "Error, Nothing Done.", -1);
}
else
{
SetWindowTitles(LittleWindow, "Disk Healed.", -1);
};
Delay(150);
SetWindowTitles(LittleWindow, TITLETEXT, -1);
}
/************************/
CheckMemoryForViruses()
{
int VirusBase; /* ick, whatta name! */
int Temp;
struct ExecBase *ExecBase;
unsigned int *LongMemPointer; /* Used for reading FROM memory */
unsigned short *loc;
unsigned int *ptr;
ExecBase = OpenLibrary("exec.library", 0);
/**************- Check for Byte Bandit (look at TD Vector) *************/
/* (Byte Bandit isn't at a fixed location. Depends on your RAM. */
/* LongMemPointer = &trackdisk.device */
LongMemPointer = FindName(&ExecBase->DeviceList, TDName);
Temp = LongMemPointer;
Temp = Temp - 0x1c;
LongMemPointer = Temp;
VirusBase = (*LongMemPointer) - 0x1b8;
LongMemPointer = VirusBase;
if (*LongMemPointer == ('D'<<24) + ('O'<<16) + ('S'<<8)) /* klugo */
{
/* Ok, so we don't really remove it from memory, but we DO render
it harmless. */
Disable();
loc = VirusBase+0xaa;
loc[0] = 0x4e71;
loc[1] = 0x4e71;
loc[2] = 0x4e71;
loc[3] = 0x4e71; /* NOP's */
loc = VirusBase+0x1c2;
loc[0] = 0x6000; /* Change Bxx to BRA */
loc = VirusBase+0x2d2;
loc[0] = 0x6000;
loc = VirusBase+0x388; loc[0] = 0x4e75; /* Make sure it doesn't come back */
loc = VirusBase + 0x3ea; loc[0] = 0; /* Kill resident matchword */
loc = VirusBase; loc[0] = 0;
Enable();
error = AutoRequest(LittleWindow, &BBMem3, &BBMPos, &BBMPos, 0, 0, 395, 78);
};
/****************- Look for Revenge Virus (at $7e000) ****************/
if (ExecBase->CoolCapture == 516192)
{
/* Fix the CoolCapture vector */
ExecBase->CoolCapture = 0;
/* Get rid of his DOS\0 in memory */
loc = 0x7e000; loc[0] = 0;
/* Patch his DoIO() wedge */
Disable();
loc = 0x7e1e0;
loc[0] = 0x4ef9;
loc[1] = 0x7;
loc[2] = 0xe066;
/* Patch his Interrupt wedge */
loc = 0x7e2da;
loc[0] = 0x4ef9;
loc[1] = 0x7;
loc[2] = 0xe06C;
Enable();
error = AutoRequest(LittleWindow, &RevMem, &BBMPos, &BBMPos, 0, 0, 395, 78);
};
/******************** See if SCA is in RAM ***************************/
if (ExecBase->CoolCapture == 0x7ec3e)
{
ExecBase->CoolCapture = 0;
error = AutoRequest(LittleWindow, &SCAMem, &BBMPos, &BBMPos, 0, 0, 395, 78);
};
/********************* Check for Byte Warrior ************************/
ptr = 0x7f800;
if (ptr[0] == ('D'<<24) + ('O'<<16) + ('S'<<8))
{
ptr = 0x7f954;
if (ptr[0] = 0x4afc)
{
ptr[0] = 0; /* Kill resident matchtag */
Forbid();
loc = 0x7f972;
loc[0] = 0x4ef9;
loc[1] = 0x00fc;
loc[2] = 0x06dc; /* jump right into the 1.2 ROMs. Ow. */
loc = 0x7f800;
loc[0] = 0;
Permit();
error = AutoRequest(LittleWindow, &ByteWarriorMem, &BBMPos, &BBMPos, 0, 0, 395, 78);
};
};
CloseLibrary(ExecBase);
}
/**************************************************************/
/* This is the routine that displauys a block as ASCII text. */
/**************************************************************/
ShowAscii(key)
int key;
{
char linebuffer[80];
int drive;
int x,y;
int deltax, deltay;
int a,b;
int FLAG=0;
struct RastPort *RP;
RP = LittleWindow->RPort;
drive = key - '0';
if ((drive < 0) || (drive > 3) || (ChangeCount[drive] == -1)) return;
error = OpenDevice(TDName,drive,diskreq,0);
if (error > 0) return;
/* Read in the selected 1K boot blok */
diskreq->io_Command = CMD_READ;
diskreq->io_Data = diskbuffer;
diskreq->io_Length = 3*512;
diskreq->io_Offset = 0;
DoIO(diskreq);
if (diskreq->io_Error > 0) return; /* disk error, lemme out */
diskreq->io_Length = 0;
diskreq->io_Command = TD_MOTOR;
DoIO(diskreq); /* turn off motor */
if (diskreq->io_Error > 0) return; /* disk error, lemme out */
CloseDevice(diskreq);
/* save the amount we moved the window */
deltax = LittleWindow->LeftEdge;
deltay = LittleWindow->TopEdge;
MoveWindow(LittleWindow, -deltax, -deltay);
SizeWindow(LittleWindow, 278, 160);
WaitForNewSize();
SetAPen(RP, 3);
Move(RP, 14+(12*8), 165);
Text(RP, "Block 0", 7);
Move(RP, 324+(12*8), 165);
Text(RP, "Block 1", 7);
SetAPen(RP, 1);
text[2] = key;
SetWindowTitles(LittleWindow, text, -1);
x=0; y=0;
SetAPen(RP, 1);
SetDrMd(RP, JAM2);
for (a=0; a<512; a=a+32)
{
Move(RP, 10+(x*8), 20+(y*9));
Text(RP, &diskbuffer[a], 32);
Move(RP, 320+(x*8), 20+(y*9));
Text(RP, &diskbuffer[a+512], 32);
y++;
};
Wait(1<<LittleWindow->UserPort->mp_SigBit);
Message = GetMsg(LittleWindow->UserPort);
/* If a disk was inserted, we want CheckBlock() to happen later on some time */
if (Message->Class == DISKINSERTED) FLAG=1;
ReplyMsg(Message);
returner:
SizeWindow(LittleWindow, -278, -160);
SetWindowTitles(LittleWindow, TITLETEXT, -1);
WaitForNewSize();
/* deltas plus current position, in case dude moved the window */
MoveWindow(LittleWindow, deltax+(-LittleWindow->LeftEdge), deltay+(-LittleWindow->TopEdge));
Delay(2);
return(FLAG);
}
/*
When you do a SizeWindow() command, you have to wait for a NEWSIZE
IntuiMessage before drawing in it. That's all this routine does.
*/
WaitForNewSize()
{
while (TRUE)
{
WaitPort(LittleWindow->UserPort);
Message = GetMsg(LittleWindow->UserPort);
if (Message->Class != NEWSIZE)
{
ReplyMsg(Message);
continue;
};
ReplyMsg(Message);
break;
};
}